package com.wuseguang.springcloud.controller;


import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.wuseguang.springcloud.Filter.RequestParameterWrapper;
import com.wuseguang.springcloud.entity.StudentFacesTwo;
import com.wuseguang.springcloud.service.StudentFacesTwoService;
import com.wuseguang.springcloud.util.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 学生人脸2.0表 前端控制器
 * </p>
 *
 * @author 
 * @since 2020-08-03
 */
@RestController
@RequestMapping("/brands")
public class StudentFacesTwoController {


    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private StudentFacesTwoService studentFacesTwoServiceImpl;


    /**
     * 查询学生人脸信息
     * @param deviceid 设备id
     * @param type 类型1注册，2删除
     * @return
     */
    @RequestMapping("/findStudentFaceTwo")
    public Result findStudentFaceTwo(@RequestParam(value = "deviceid") String deviceid,
                                  @RequestParam(value = "type") Integer type) {
        logger.info("查询学生人脸信息 deviceid = {},查询类型 = {}", deviceid,type);
        return studentFacesTwoServiceImpl.findStudentFaceTwo(deviceid,type);
    }

    /**
     * 告知学生人脸注册情况
     *
     * @param faceList
     * @return
     */
    @RequestMapping("/informStudentFaceTwo")
    public Result informStudentFaceTwo(@RequestParam(value = "faceList") String faceList,
                                    @RequestParam(value = "deviceid") String deviceid) {
        logger.info("告知人脸注册情况 ");

        JSONArray list = JSONObject.parseArray(faceList);

        return studentFacesTwoServiceImpl.informStudentFaceTwo(list, deviceid);
    }
}

